﻿@using Freesql.Tool.Helpers;
@using Freesql.Tool.Models;
@using System.Collections.Generic;
@{
    var gen = Model as Freesql.Tool.Models.RazorTemplateModel;
    var list = ReflectionHelper.GetEnums();
    string GetColor(int i)
    {
        var color = new string[] { "pink", "red", "orange", "green", "cyan", "blue", "purple" };
        if (i > color.Length - 1)
        {
            return color[0];
        }
        return color[i];
    }
}
/**
* 枚举对应注释
*/
export const Values = {
@foreach (var item in list)
{
    @:@item.Name: {
    @for (var i = 0; i < item.EnumInfos.Count; i++)
    {
        var eitem = item.EnumInfos[i];
        @:'@eitem.Value' : { desc : '@eitem.Desc' , color : '@GetColor(i)'}@(i != (item.EnumInfos.Count-1) ?",":"")
    }
    @:},
}
}

/**
* api code代码
*/
export enum Code {
  /**
  * 成功
  */
  ok = 0,
  /**
  * 失败
  */
  error = -1
}
@foreach (var item in list)
{
@:
@: /**
@:* @item.Desc
@:*/
@: export enum @item.Name {
for (var i = 0; i < item.EnumInfos.Count; i++)
{
    var eitem = item.EnumInfos[i];
    @:/**
    @:* @(eitem.Desc)
    @:*/
    @($"  {eitem.Name} = {eitem.Value}{(i != (item.EnumInfos.Count-1) ? ",":"")}")
    @:
}
@:}
}